 
  var os="android";
if (/ipad|iphone|mac/i.test(navigator.userAgent)){
	os="ios";		
}
var soundplayer=new Audio();
soundplayer.src="/static/neworder.mp3";
soundplayer.preload="auto";
soundplayer.volume=1;
var isforce=false;
soundplayer.oncanplay=function(){
				isforce=true;
};
var neworder=false;
function forceSafariPlayAudio() {
		if(os!="ios") return false;
		if(isforce) return false;
			
			if(neworder){
				soundplayer.load();
				soundplayer.play();
				isforce=true;
			}else{
		   		soundplayer.load();
			}
		   
}
window.addEventListener('touchstart', forceSafariPlayAudio, false);

function refreshOrder(){
	if(localStorage.getItem("newordermp3")==1){
		$("#js-bgplay").show();
		$("#js-bgpause").hide();
	}else{
		$("#js-bgplay").hide();
		$("#js-bgpause").show();
		$.get("/koudaiadmin.php?m=koudai_order&a=newjs&t="+new Date(),function(data){
				if(data.success==1){
					soundplayer.play();
					neworder=true;
				}else{
					neworder=false;
				}
			},"json")
	}
	setTimeout(function(){
			refreshOrder();
		},30000);	
}
	$(function(){
		refreshOrder();
	});

$(function(){
	$("#js-bgpause").on("click",function(){
		$(this).hide();
		$("#js-bgplay").show();
		localStorage.setItem("newordermp3",1)
		soundplayer.volume=0;
	});
	$("#js-bgplay").on("click",function(){
		$(this).hide();
		$("#js-bgpause").show();
		localStorage.setItem("newordermp3",0)
		soundplayer.volume=1;
	});
})